home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_559 / apig / apiglib_v11.lzh / e8_blits.rexx < prev    next >
OS/2 REXX Batch file  |  1991-09-28  |  4KB  |  147 lines

  1.  
  2. /* Example using the Blt... functions   */
  3. /* refer to your favorite Amiga reference for discussion on MINTERMs */
  4.  
  5.  x = addlib("apig.library",0,-30,0)
  6.  
  7.  portname = "example8_port"
  8.  p = openport(portname)
  9.  call set_apig_globals()
  10.  
  11.  scrtitle = "Hey Buddy, Yea You,  This is Your New Screen  !"
  12.  wintitle = "This is your title"
  13.  winidcmp = CLOSEWINDOW+GADGETDOWN+GADGETUP
  14.  winflags = WINDOWCLOSE+WINDOWDRAG+WINDOWSIZING+WINDOWDEPTH+GIMMEZEROZERO
  15.  
  16.  scr = openscreen(0,0,640,400,3,4,5,LACE+HIRES,CUSTOMSCREEN,scrtitle)
  17.  
  18.  
  19.  /* open window */
  20. w1  = openwindow(portname,0,0,640,400,2,4,winidcmp,winflags,wintitle,scr,0,0,0)
  21.  
  22. rpw1 = getwindowrastport(w1) 
  23. windowsbitmap = getrpbitmap(rpw1)  /* points to the window rastport bitmap */
  24.  
  25. bitmap1 = loadiff("bitmap")
  26. bitmap2 = loadiff("bitmap2")
  27.  
  28. width1  = bmwidth(bitmap1)
  29. height1 = bmheight(bitmap1)
  30. depth1  = bmdepth(bitmap1)
  31.   
  32. width2  = bmwidth(bitmap2)
  33. height2 = bmheight(bitmap2)
  34. depth2  = bmdepth(bitmap2)
  35.   
  36.  
  37.   
  38. /* --- Bltbitmap --- */
  39.  
  40. x = bltbitmap(bitmap1,0,0,windowsbitmap,270,60,width1,height1,c2d('00c0'x),15,0)
  41.  
  42. x = bltbitmap(bitmap2,0,0,windowsbitmap,270,90,width2,height2,c2d('00c0'x),15,0)
  43.   
  44. z = pitext(rpw1,140,110," You probably didn't notice but ...",0,6,JAM2,0,0)  
  45. z = pitext(rpw1,140,121," the above images were 'BLITTED' ",0,6,JAM2,0,0)  
  46. z = pitext(rpw1,204,133," using BLTBITMAP() ",0,6,JAM2,0,0)  
  47. wait 2 secs
  48.  
  49. /* --- Bltbitmaprastport --- */
  50.  
  51. z = pitext(rpw1,204,145," gonna blit using BLTBITMAPRASTPORT() now ...",0,6,JAM2,0,0)  
  52. wait 1 secs
  53. x = bltbitmaprastport(bitmap1,0,0,rpw1,270,200,width1,height1,c2d('00c0'x),15)
  54.  
  55. x = bltbitmaprastport(bitmap2,0,0,rpw1,270,220,width2,height2,c2d('00c0'x),15)
  56.  
  57.  
  58. /* --- blitting through a mask --- */
  59.  
  60. numbytes = (( width1 * height1 ) / 8) + 8  /* forgot why I added 8 here */
  61.                                            /* suspect just so I had enough mem */
  62.  
  63. mask = allocmem(numbytes,MEMF_CHIP)  /* need chip mem for mask */
  64.  
  65. do i = 0 to ((numbytes - 8) / 2 )  /* div. by 2, cuz set two bytes at a time */
  66.    x = setarray(mask,i,c2d('f00f'x)) /* fill mask mem with 0xf00f */
  67. end
  68.  
  69. z = pitext(rpw1,204,155," gonna blit using BLTMASKBITMAPRASTPORT() now ...",0,6,JAM2,0,0)  
  70. wait 1 sec
  71.  
  72. /* the minterm in this blit copies thru the mask */
  73. x = bltmaskbitmaprastport(bitmap1,0,0,rpw1,150,155,width1,height1,c2d('00e0'x),mask)
  74.  
  75. /* the minterm in this blit copies thru the mask and inverts */
  76. x = bltmaskbitmaprastport(bitmap2,0,0,rpw1,99,155,width2,height2,c2d('0020'x),mask)
  77.  
  78. /* --- Bltpattern --- */
  79.  
  80.   z = pitext(rpw1,204,176," blit using BLTPATTERN ...",0,6,JAM2,0,0)  
  81.   do i = 0 to ((numbytes-8)/2)
  82.      x = setarray(mask,i,c2d('0ff0'x))  /* reusing mask as pattern */
  83.                                         /* pattern must be chipmem */
  84.   end
  85.  
  86.  
  87.   x = setapen(rpw1,2)
  88.   x = setbpen(rpw1,3)
  89.   x = setdrmd(rpw1,JAM2)
  90.   x = bltpattern(rpw1,mask,152,176,200,188,(width1/8))
  91.   
  92. /* --- Blttemplate --- */
  93.  
  94.   z = pitext(rpw1,204,192," blit using BLTTEMPLATE ...",0,6,JAM2,0,0)  
  95.   x = blttemplate(mask,0,6,rpw1,152,192,48,12)
  96.  
  97.  
  98.  
  99. /* --- clipblit from one rastport to another --- */
  100.  
  101. rp2 = makerastport( 300, 220, depth1) /* make offscreen rastport */
  102. do x = 0 to 180 by width1    /* putting multiple copies into rp2 */   
  103.    do y = 0 to 180 by height1
  104.       /* blit the bitmap into rp2 (ie. copy it) */
  105.       z = bltbitmaprastport(bitmap1,0,0,rp2,x,y,width1,height1,c2d('00c0'x),15)
  106.    end
  107. end
  108.  
  109. wait 2 secs
  110. z = pitext(rpw1,190,280," <--- This is being done with CLIPBLIT()...",3,2,JAM2,0,0)  
  111. z = pitext(rpw1,190,292,"        with varying minterm values.       ",3,2,JAM2,0,0)  
  112.  
  113. do i = 0 to 255 by 16   /* NOW BLIT FROM RP2 TO THE WINDOWS RASTPORT */
  114.    z = clipblit(rp2,0,0,rpw1,90,210,99,99,i)
  115.    wait 1 sec
  116. end
  117.  
  118.  
  119.  
  120.  
  121. z = pitext(rpw1,200,315," Im Done ...",1,2,JAM2,0,0)  
  122. exitme = 0
  123. do forever
  124.  
  125.      x = waitpkt(portname)
  126.   
  127.      do forever 
  128.         msg = getpkt(portname)
  129.         if msg = '0000 0000'x then leave
  130.         class = getarg(msg,0)
  131.         if class = CLOSEWINDOW then exitme = 1
  132.         x = reply(msg,0)  
  133.      end  
  134.    if exitme = 1 then leave
  135.    
  136. end
  137.  
  138.   x = freemem(mask,numbytes)
  139.   
  140.   x = freebitmap(bitmap1)
  141.   x = freebitmap(bitmap2)
  142.   x = freerastport(rp2)
  143.   
  144.   a =closewindow(w1)
  145.   a =closescreen(scr)
  146.   exit
  147.